package edu.pe.cayetano.util;

import java.util.ArrayList;
import java.util.LinkedHashMap;
import java.util.List;
import java.util.Map;
import java.util.TreeSet;

public class UtilCollections {

	public static Map ordenarElementosMap(Map hashtable){
        List mapKeys = new ArrayList(hashtable.keySet());
        List mapValues = new ArrayList(hashtable.values());
        hashtable.clear();
        TreeSet sortedSet = new TreeSet(mapKeys);
        Object[] sortedArray = sortedSet.toArray();
        hashtable = new LinkedHashMap();
        for (int i = 0; i < sortedArray.length; i++) {
            hashtable.put(sortedArray[i], mapValues.get(mapKeys.indexOf(sortedArray[i])));
        }
        return hashtable;
	}
}
